package com.ycc.usercenter.common;

import lombok.Data;

import java.io.Serializable;

/**
 * 返回通用类
 */
@Data
public class BaseResponse<T>  implements Serializable {

    // 返回数据
    private T data;
    // 返回状态码
    private int code;
    // 返回描述信息
    private String message;
    // 返回描述信息（详细）
    private String description;

    public BaseResponse(T data, int code, String message, String description) {
        this.data = data;
        this.code = code;
        this.message = message;
        this.description = description;
    }

    public BaseResponse(T data, int code, String message) {
        this(data, code, message, "");
    }

    public BaseResponse(T data, int code) {
        this(data, code, "", "");
    }

    public BaseResponse(ErrorCode errorCode) {
        this(null, errorCode.getCode(),errorCode.getMessage(),errorCode.getDescription());
    }

    public BaseResponse(int code, String message, String description) {
        this(null, code, message, description);
    }
}
